package com.mustang.core.client.type;
import com.google.gwt.core.client.JavaScriptObject;

/**
 * This class represents the JS object like <code>var obj={}</code> Supported
 * value is as below: 
 * <@code>String.java</@code>
 * <@code>java.util.Date.java</@code>
 * <@code>int</@code>
 * <@code>boolean</@code>
 * <@code>double</@code>
 * <@code>JsObject.java</@code>
 * <@code>JsArray.java</@code> 
 * Unsupported value is as below:
 * <@code>Func.java</@code>
 * 
 * For example:set property for JsObject 
 * JsObject d=JsObject.$O(); 
 * d.set("att1", "a string value");
 * d.set("att2", 3); 
 * d.set("att3", 3.6); 
 * d.set("att4", new Date());
 * d.set("att5", true); 
 * d.set("att6", JsArray.$A(1,2,3));
 * 
 * @author Jason.Cui
 * 
 */
public class JsObject extends JavaScriptObject
{
	protected JsObject()
	{
	}
	
	
	//Static Methods
	/**
	 * Return the JsAttribute Object
	 */
	public static JsObject $O()
	{
		return JavaScriptObject.createObject().cast();
	}

	
	//Public Methods
	
	/**
	 * Add property for JsObject by given <code>key</code> and <code>value</code>
	 * 
	 */
	public final native JsObject set(String key, int value)/*-{
		this[key]=value;
		return this;
	}-*/;

	public final native JsObject set(String key, double value)/*-{
		this[key]=value;
		return this;
	}-*/;

	public final native JsObject set(String key, String value)/*-{
		this[key]=value;
		return this;
	}-*/;

	public final native JsObject set(String key, boolean value)/*-{
		this[key]=value;
		return this;
	}-*/;

	public final native JsObject set(String key, JsObject value)/*-{
		this[key]=value;
		return this;
	}-*/;

	public final native JsObject set(String key, JsArray<?> value)/*-{
		this[key]=value;
		return this;
	}-*/;

	
	public final native int getInt(String key)/*-{
		return this[key];
	}-*/;

	public final native String getString(String key)/*-{
		return this[key];
	}-*/;

	public final native double getDouble(String key)/*-{
		return this[key];
	}-*/;

	public final native JsObject getJsObject(String key)/*-{
		return this[key];
	}-*/;

	public final native JsArray<?> getJsArray(String key)/*-{
		return this[key];
	}-*/;

	public final native boolean getBoolean(String key)/*-{
		return this[key];
	}-*/;

}
